home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / DOCZ16.ZIP;1 / DOCZ.LIF / HASPRIV.C < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-24  |  2.1 KB  |  86 lines

  1. #ifdef DOCUMENTATION
  2.  ******************************* DOCZ Header *********************************
  3. .MODULE                 haspriv
  4. .LIBRARY              csub
  5. .TYPE                  function
  6. .APPLICATION         system
  7. .SYSTEM                 vms
  8. .AUTHOR                 Software Toolz
  9. .LANGUAGE             C
  10. .DESCRIPTION
  11.     Test your process for priviledges
  12. .ARGUMENTS
  13.     haspriv(privmask)
  14.         int    privmask;            /* (r) the priviledge(s) to test */
  15. .NARRATIVE
  16.     The Haspriv function tests the current process for one or more
  17.     priviledges specified as a mask.
  18. .RETURNS
  19.     Non-zero if the process has the specified privilege(s), 0 if not or on
  20.     system call failure.
  21. .INCLUDES
  22.     <prvdef.h>
  23.     "csub.h"
  24. .EXAMPLE
  25.     #include <prvdef.h>
  26.  
  27.     if (haspriv(PRV$M_TMPMBX))
  28.         puts("TMPMBX");
  29.     if (haspriv(PRV$M_NETMBX))
  30.         puts("NETMBX");
  31.     if (haspriv(PRV$M_SYSPRV |PRV$M_CMKRNL))
  32.         puts("SYSPRV or CMKRNL");
  33. .NOTICE
  34.     Copyright 1989 Software Toolz, Inc. - Atlanta, Georgia
  35.  
  36.     All rights reserved worldwide.  This program may not be reproduced,
  37.     transmitted, transcribed, stored in a retrieval system or translated in 
  38.     any human or computer language, in any form without the express written 
  39.     permission of Software Toolz, Inc.
  40. .ENDOC                 END DOCUMENTATION
  41.  *****************************************************************************
  42. #endif
  43.  
  44. #include <stdio.h>
  45. #include <ctype.h>
  46. #include <jpidef.h>
  47. #include <ssdef.h>
  48. #include <prvdef.h>
  49. #include "csub.h"
  50. #include "csubmac.h"
  51.  
  52. /*****************************************************************************
  53.     Getjobs
  54. *****************************************************************************/
  55. haspriv(privmask)
  56.     int    privmask;            /* (r) the priviledge(s) to test */
  57. {
  58.     int    privs [2],            /* priviledge mask */
  59.             privlen,
  60.             u;
  61.     struct
  62.     {
  63.         short     buffer_len,
  64.                     item_code;
  65.         POINTER    buff_addr,
  66.                     ret_addr;
  67.         int        terminator;
  68.     } itemlist =
  69.     {
  70.         sizeof(privs),
  71.         JPI$_CURPRIV,
  72.         privs,
  73.         &privlen,
  74.         0
  75.     };
  76.  
  77.     if (VMSOK(SYS$GETJPIW(0,0,0,&itemlist,0,0,0)))
  78.     {
  79.         u = privs[0] & privmask;
  80.         return (u);
  81.     }
  82.  
  83.     return 0;                    /* return FALSE for system call failure */
  84.  
  85. }    /* end haspriv */
  86.